package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SuperCommentImage;
import com.ruoyi.system.service.ISuperCommentImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 评论图片,存储评论福袋图片URLController
 * 
 * @author ruoyi
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/comment/images")
public class SuperCommentImageController extends BaseController
{
    @Autowired
    private ISuperCommentImageService superCommentImageService;

    /**
     * 查询评论图片,存储评论福袋图片URL列表
     */
    @PreAuthorize("@ss.hasPermi('comment:images:list')")
    @GetMapping("/list")
    public TableDataInfo list(SuperCommentImage superCommentImage)
    {
        startPage();
        List<SuperCommentImage> list = superCommentImageService.selectSuperCommentImageList(superCommentImage);
        return getDataTable(list);
    }

    /**
     * 导出评论图片,存储评论福袋图片URL列表
     */
    @PreAuthorize("@ss.hasPermi('comment:images:export')")
    @Log(title = "评论图片,存储评论福袋图片URL", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SuperCommentImage superCommentImage)
    {
        List<SuperCommentImage> list = superCommentImageService.selectSuperCommentImageList(superCommentImage);
        ExcelUtil<SuperCommentImage> util = new ExcelUtil<SuperCommentImage>(SuperCommentImage.class);
        util.exportExcel(response, list, "评论图片,存储评论福袋图片URL数据");
    }

    /**
     * 获取评论图片,存储评论福袋图片URL详细信息
     */
    @PreAuthorize("@ss.hasPermi('comment:images:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(superCommentImageService.selectSuperCommentImageById(id));
    }

    /**
     * 新增评论图片,存储评论福袋图片URL
     */
    @PreAuthorize("@ss.hasPermi('comment:images:add')")
    @Log(title = "评论图片,存储评论福袋图片URL", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuperCommentImage superCommentImage)
    {
        return toAjax(superCommentImageService.insertSuperCommentImage(superCommentImage));
    }

    /**
     * 批量新增评论图片,存储评论福袋图片URL
     */
    @PreAuthorize("@ss.hasPermi('comment:images:add')")
    @Log(title = "评论图片,存储评论福袋图片URL", businessType = BusinessType.INSERT)
    @PostMapping("/batch")
    public AjaxResult addBatch(@RequestBody List<SuperCommentImage> superCommentImageList)
    {
        return toAjax(superCommentImageService.insertBatchSuperCommentImage(superCommentImageList));
    }

    /**
     * 修改评论图片,存储评论福袋图片URL
     */
    @PreAuthorize("@ss.hasPermi('comment:images:edit')")
    @Log(title = "评论图片,存储评论福袋图片URL", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SuperCommentImage superCommentImage)
    {
        return toAjax(superCommentImageService.updateSuperCommentImage(superCommentImage));
    }

    /**
     * 删除评论图片,存储评论福袋图片URL
     */
    @PreAuthorize("@ss.hasPermi('comment:images:remove')")
    @Log(title = "评论图片,存储评论福袋图片URL", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(superCommentImageService.deleteSuperCommentImageByIds(ids));
    }
}
